<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        function showSex(){
            var sex = document.querySelector("[name='sex']:checked").value;
            alert(sex);

        }
        function showLike(){
           var array =  document.querySelectorAll("[name='like']:checked");
           for(var i=0;i<array.length;i++){
               console.log("---------"+array[i].value);
           }
        }
        window.onload = function (){
            var imgArray = document.querySelectorAll("#myDiv img");
            for(var i=0;i<imgArray.length;i++){
                console.log("----------"+imgArray[i].src);
            }
        }
    </script>
</head>
<body>
    首页

    <input type="radio" name="sex" value="男" checked>男
    <input type="radio" name="sex" value="女">女
    <input type="radio" name="sex" value="李宇春">李宇春
    <input type="button" value="点击" onclick="showSex()">
    <hr>
    <input type="checkbox" name="like" value="1">体育
    <input type="checkbox" name="like" value="2">音乐
    <input type="checkbox" name="like" value="3">美术
    <input type="button" value="显示爱好" onclick="showLike()">

    <div id="myDiv"><img src="1"><img src="2"></div>

</body>
</html>